package com.unione.unione_base.bean

import androidx.annotation.Keep
import com.squareup.moshi.JsonClass

@Keep
@JsonClass(generateAdapter = true)
open class BaseRobotAppRepo<T>(
    val code: Int? = null,
    val message: String? = null,
    val data: T? = null,
) {
    fun isSuccess(): Boolean {
        return code == 200
    }
}

inline fun <T> BaseRobotAppRepo<T>.success(block: () -> Unit): BaseRobotAppRepo<T> {
    block()
    return this
}

inline fun <T> BaseRobotAppRepo<T>.failure(block: () -> Unit): BaseRobotAppRepo<T> {
    if (!this.isSuccess()) {
        block()
    }
    return this
}

fun <T> BaseRobotAppRepo<T>.error(block: () -> BaseRobotAppRepo<T>) {

}